package com.CMS.server.domain;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = EntityTokens.USER_TABLE)
public class User extends BaseEntity{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4459744586176383142L;

	@Column(name = EntityTokens.USER_MAIL_COLUMN, length = EntityTokens.USER_MAIL_LENGTH,
			nullable = EntityTokens.USER_MAIL_NULLABLE)
	protected String mail;
	
	@Column(name = EntityTokens.USER_ALIAS_COLUMN, length = EntityTokens.USER_ALIAS_LENGTH,
			nullable = EntityTokens.USER_ALIAS_NULLABLE, unique = true)
	protected String alias;
	
	@Column(name = EntityTokens.USER_PASSWORD_COLUMN, length = EntityTokens.USER_PASSWORD_LENGTH,
			nullable = EntityTokens.USER_PASSWORD_NULLABLE)
	protected String password;
	
	//@OneToOne(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	//@JoinColumn(name = EntityTokens.ROL_ID_JOINNED, nullable = true)
	@ManyToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	protected Rol rol;
	
	@ManyToOne(cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	protected Language lang;
	
	public User(){
		super();
	}
	
	public String getMail() {
		return mail;
	}
	public void setMail(String mail) {
		this.mail = mail;
	}
	public String getAlias() {
		return alias;
	}
	public void setAlias(String alias) {
		this.alias = alias;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	
	public void setRol(Rol rol){
		this.rol = rol;
	}
	
	public Rol getRol(){
		return this.rol;
	}

	public Language getLang() {
		return lang;
	}

	public void setLang(Language lang) {
		this.lang = lang;
	}
	 
}
